package dse.modules;

import java.util.Map;
import dse.DataObject;
import dse.DseException;
import dse.ExperimentConfiguration;

public class SimpleShareRequestDecisionMaker
implements ShareRequestDecisionMaker
{
	private int delta;
	
	public void initalize (
			ExperimentConfiguration systemSettings,
			Map<String, String> moduleSettings
			)
	throws DseException
	{
		// This is a simple module, nothing to do here.
		ModuleUtil.SettingsReader sr = ModuleUtil.getSettingsReader(
				this.getClass(), moduleSettings
				);
		delta =  sr.getInteger("delta");
	}
	
	/**
	 * Returns the number of shares that should be requested concurrently when
	 * a node wants to download the passed dataObject.
	 *  
	 * @param dataObject
	 * @return	The number of shares to initally request concurrently. 
	 */
	public int sharesToRequestFor (DataObject dataObject) {
		return dataObject.requiredShareCount()+delta;
	}
}